<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>已发布管理</title>
    <#include "/common/resource.ftl">
    <style type="text/css">
    .panel-body{background: #eaedef;}
    .panel-header{background: #fafafa;}
    .tabs-header, .tabs-tool {background-color: #Fafafa;}
	.datagrid .panel-body {background: #fff;}
	.datagrid-header-row, .datagrid-row {height: 25px;}
	.panel-toolbar{background: #fff;overflow: hidden;}
	.panel-toolbar .toolbar-left{margin-left: 10px;height: 100%;float: left;}
	.panel-toolbar .toolbar-left .toolbar-item {float: left;padding-top: 10px;padding-left: 5px;}
	.toolbar-right{margin-right: 10px;height: 100%;float: right;padding-top: 10px;}
	.panel-toolbar .toolbar-left .toolbar-item .form-control{border: 1px solid #ccc;border-radius:3px; font-size: 9pt;height: 27px;width:200px;padding-top: 0;padding-bottom: 0px;padding-right: 0;padding-left: 5px;}
	.panel-toolbar .toolbar-left .toolbar-item .form-control:focus{border: 1px solid #1E9FFF;}
    </style>
    <script type="text/javascript">
        var getSearchParams = function(){
            return {
            	searchInput:$("input[name='searchInput']").val() || "",
            };
        }
    </script>
</head>
<body class="easyui-layout" fit="true" border="false">
<div data-options="region:'north'" border="false" style="height: 86px;padding: 10px;padding-bottom: 0px;">
		<div class="easyui-panel panel-toolbar" title="指令列表" border="true" fit="true" style="border-bottom: none;">
       		<div class="toolbar-left">
       			<div class="toolbar-item">
                       <input id="keyword" name="searchInput" type="text" class="form-control" placeholder="输入指令标题、关键字查询">
                   </div>
                   <div class="toolbar-item">
                       <button class="layui-btn layui-btn-small layui-btn-normal search-button" style="border-radius: 3px;"><i class="fa fa-search"></i> 查询</button>
                   </div>
       		</div>
       		<div class="toolbar-right">
       			
       			<div class="layui-btn-group">
                    <button class="layui-btn layui-btn-normal open-dialog" p="url:'${params.contextPath}/view/icip/instruction/instruction_publish.htm',title:'发布指令',width:'90%',height:'95%'">
						<i class="fa fa-plus"></i>发布新指令
					</button>
					<button class="layui-btn layui-btn-normal remove-button" reurl="${params.contextPath}/web/instruction/delete.json">
						<i class="fa fa-remove"></i>删除
					</button>
				</div>
       		</div>
       	</div>
	</div>
	<div data-options="region:'center'" border="false" style="padding: 10px;padding-bottom: 4px;padding-top: 0px;">
       <table id="datagrid" options="url:'${params.contextPath}/web/instruction/page.json',params:'getSearchParams',dblClickRow:'showDetail',fit:true,onSelect:showTask,onLoadSuccess:loadSuccess">
			<thead>
               	<tr>
               		<th data-options="field:'ck',checkbox:true"></th>
                   <th data-options="field:'title',width:150">指令标题</th>
                   <th data-options="field:'keyword',width:120">关键字</th>
                   <th data-options="field:'typeStr',width:80">指令模板</th>
                   <th data-options="field:'senderName',width:60">签发人</th>
                   <th data-options="field:'senderOrgName',width:100">签发单位</th>
                   <th data-options="field:'sendTimeStr',width:100">发布时间</th>
                   <th data-options="field:'_count',width:150,formatter:formatStatistic">指令统计</th>
                   
				</tr>
			</thead>
       </table>
   </div>
	<div data-options="region:'south'" border="false" style="padding: 10px;height: 35%;padding-top: 0px;">
		<div class="easyui-tabs" fit="true">
			<div title="反馈列表" style="padding:4px;background: #fff; ">
				<table id="datagrid-feedback" data-options="fitColumns:true,fit:true,onDblClickRow:showFeedbackDetail" >
			        <thead>
			            <tr>
			            	<th data-options="field:'title',width:120">反馈标题</th>
			            	<th data-options="field:'templateName',width:120">信息报送模板</th>
			            	<th data-options="field:'userName',width:60">反馈人</th>
			            	<th data-options="field:'orgName',width:80">反馈单位</th>
			                <th data-options="field:'createtimeStr',width:100">反馈时间</th>
			            </tr>
			        </thead>
		    	</table>
		    </div>
	        <div title="接收单位列表" style="padding:4px;background: #fff; ">
				<table id="datagrid-task" data-options="fitColumns:true,fit:true" >
			        <thead>
			            <tr>
			            	<th data-options="field:'orgName',width:120">接收单位</th>
			            	<th data-options="field:'stateStr',width:60">处理状态</th>
			            	<th data-options="field:'signTimeStr',width:100">签收时间</th>
			                <th data-options="field:'feedbackCount',width:60">反馈数</th>
			            </tr>
			        </thead>
		    	</table>
		    </div>
		    <div title="处理日志列表" style="padding:4px;background: #fff; ">
				<table id="datagrid-log" data-options="fitColumns:true,fit:true" >
			        <thead>
			            <tr>
			            	<th data-options="field:'type',width:60">处理类型</th>
			            	<th data-options="field:'content',width:150">处理内容</th>
			            	<th data-options="field:'operatorName',width:60">处理人</th>
			            	<th data-options="field:'orgName',width:100">处理单位</th>
			            	<th data-options="field:'operateTimeStr',width:100">处理时间</th>
			               
			            </tr>
			        </thead>
		    	</table>
		    </div>
		 </div>
		
	</div>
   
</body>
<script type="text/javascript">

$(function(){

	$(".remove-button").click(function() {
		var ids = DataGrid.getCheckedIds();
		if (ids == "") {
			layer.msg("请选择删除记录")
			return false;
		}
		var url = $(this).attr("reurl");
		layer.confirm('确定删除记录', function() {
			$.ajaxRequest({
				url : url,
				data : {
					ids : ids.join(",")
				},
				success : function(data) {
					$.message(data.message);
					if (data.success) {
						DataGrid.reload();
					}
				}
			});
		});
	});
    
});

function loadSuccess(){
	$("#datagrid").datagrid("selectRow",0);
}


function showTask(){
	var id = DataGrid.getSelectId();
	var state = 0;
	$("#datagrid-task").datagrid({
		url:'${params.contextPath}/web/instructionTask/list.json?instructionid='+id
	});
	
	$("#datagrid-feedback").datagrid({
		url:'${params.contextPath}/web/instructionFeedBack/list.json?instructionid='+id
	});
	
	$("#datagrid-log").datagrid({
		url:'${params.contextPath}/web/instructionLog/logList.json?instructionid='+id
	});
}

function showFeedbackDetail(index, row){
	var url = "${params.contextPath}/view/icip/instruction/instruction_feedback_detail.htm?id=" + row.id;
    DialogManager.openDialog("url:'" + url + "',title:'指令反馈详情',width:'90%',height:'95%'");
}

function showDetail (index, row) {
    var url = "${params.contextPath}/view/icip/instruction/instruction_detail.htm?id=" + row.id;
    DialogManager.openDialog("url:'" + url + "',title:'指令详情',width:'90%',height:'95%'");
}
function openReplyDialog(id,state){
	
    var params = {url:'${params.contextPath}/view/icip/instruction/instruction_feedback_task.htm',title:'指令任务查询',width:'800px',height:'90%'};
    params.url = $.getUrl(params.url, "id", id);
    params.url = $.getUrl(params.url, "state", state);
	DialogManager.openDialog(JSON.stringify(params).replace("{", "").replace("}", ""));
}
function formatStatistic(val,row){
	var html = '<span class="ui-accept" >应反馈['+row.totalFeedbackCount+']</span>';
	html += '&nbsp;|&nbsp;<span class="ui-accept" >实反馈['+row.realFeedbackCount+']</span>';
	html += '&nbsp;|&nbsp;<span class="ui-accept" >日志</span>';
	return html;
}
</script>
</html>
